<?php
// +----------------------------------------------------------------------
// | [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Author < 931274989@qq.com >
// +----------------------------------------------------------------------
// | Explain 会员提现
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\admin\model\Tixian as tixianModel;
use think\Controller;
use think\Db;

class Tixian extends Controller
{
  
  public function lst()
  {
    $model = new tixianModel();
    $tixian = $model::with('user')->order('id desc')->paginate(20);
    $this->assign('tixian',$tixian);
    return view();
  }

  public function status()
  {
    $id = $this->request->has('id') ? $this->request->param('id', 0, 'intval') : 0;
    if($id > 0) {
      if($this->request->isPost()) {
        $post = $this->request->post();
        $starts = $post['status'];
        $result = Db::name('tixian')->where('id',$id)->update(['starts'=>$starts]);
        if(!$result) {
          return $this->error('提交失败');
        } else {
          return $this->success('提交成功','admin/tixian/lst');
        }
      }
    } else {
      return $this->error('id不正确');
    }
  }

  public function del()
  {
    if($this->request->isAjax()) {
      $id = $this->request->has('id') ? $this->request->param('id', 0, 'intval') : 0;
      if(false == Db::name('tixian')->where('id',$id)->delete()) {
        return $this->error('删除失败');
      } else {
        return $this->success('删除成功','tixian/lst');
      }
    }
  }
  
}
?>